<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/jq.mselect.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.multiselect.js"></script>
<script type="text/javascript">
$(function(){
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
	$("#request_download").click(function(){
		var url_arr_json = $(this).prev().val();
		window.location.href="<?=url('DataCenter::Sales/UnshippedOrderStatisDownload')?>&url_arr_json=" + url_arr_json;
	});
	$("#multiselect").multiselect({height: 260, minWidth: 160});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>查询日期</th>
	<td>
		<input value="<?=isset($_GET['end_time']) ? date('Y-m-d' ,strtotime($_GET['end_time'].'- 30day')) : '' ?>" class="datepicker" id="begin_time" disabled="disabled" /> to
		<input name="end_time" value="<?=isset($_GET['end_time']) ? $_GET['end_time'] : ''?>" class="datepicker" id="end_time"/>
	</td>
</tr>
<tr>
	<th>网站店铺</th>
	<td>
		<select name="shop_id[]" multiple="multiple" id="multiselect">
		<?foreach ($shop_group as $k => $sg):?>
		<optgroup label="<?=$k?>">
		<?foreach ($sg as $s):?>
		<option value="<?=$s['id']?>" <?if (isset($_GET['shop_id']) && is_array($_GET['shop_id']) && in_array($s['id'], $_GET['shop_id'])) echo "selected='selected'"?>><?=$s['name']?></option>
		<?endforeach;?>
		</optgroup>
		<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<td></td>
	<td><input type="submit" class="button" value="查询" /></td>
	<td>
		<?if (isset($_GET['end_time']) && $_GET['end_time']):?>
		<input type="hidden" value='<?=$url_arr_json?>' />
		<input type="button" class="button" value="请求下载" id="request_download" />
		<?endif;?>
	</td>
</tr>
</table>
</form></fieldset>
<?if (isset($_GET['end_time']) && $_GET['end_time']):?>
<?$total_count = $total_amount = $total_unshipped_count = $total_unshipped_amount = 0;?>
<table class="list_table" width="100%">
<tr>
	<th>未处理时间</th>
	<th>对应日期</th>
	<th>订单总数量</th>
	<th>未发货订单数</th>
	<th>未发货订单数比例</th>
	<th>订单总金额</th>
	<th>未发货订单总金额</th>
	<th>未发货理订单金额比例</th>
</tr>
<?foreach ($unshipped_order_statis as $k => $u):?>
<?
$total_count += $u['count'];
$total_amount += $u['amount'];
$total_unshipped_count += $u['unshipped_count'];
$total_unshipped_amount += $u['unshipped_amount'];
?>
<tr>
	<td><?=$k?></td>
	<td><?=$u['date']?></td>
	<td><?=$u['count']?></td>
	<td><?=$u['unshipped_count']?></td>
	<td><?=number_format($u['unshipped_count_PCT'], 2)?>%</td>
	<td><?=number_format($u['amount'], 2)?></td>
	<td><?=number_format($u['unshipped_amount'], 2)?></td>
	<td><?=number_format($u['unshipped_amount_PCT'], 2)?>%</td>
</tr>
<?endforeach;?>
<tr>
	<td>合计</td>
	<td>—</td>
	<td><?=$total_count;?></td>
	<td><?=$total_unshipped_count;?></td>
	<td><?=number_format($total_unshipped_count/$total_count*100, 2)?>%</td>
	<td><?=number_format($total_amount, 2);?></td>
	<td><?=number_format($total_unshipped_amount, 2);?></td>
	<td><?=number_format($total_unshipped_amount/$total_amount*100, 2)?>%</td>
</tr>
</table>
<?endif;?>
<?php $this->_endblock();?>